From a1d3c13679e97658c98d46c030bb9e2e3bd55e66 Mon Sep 17 00:00:00 2001 From: Gianni Tedesco Date: Thu, 29 Jul 2010 18:49:47 +0100 Subject: [PATCH] libxl: Move libxl_device_pci_reset to libxl_pci.c Signed-off-by: Gianni Tedesco Committed-by: Ian Jackson --- tools/libxl/libxl_device.c | 34 ---------------------------------- tools/libxl/libxl_pci.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 34 deletions(-) diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c index 226ae5539e..c59c631457 100644 --- a/tools/libxl/libxl_device.c +++ b/tools/libxl/libxl_device.c @@ -377,40 +377,6 @@ int libxl_device_del(libxl_ctx *ctx, libxl_device *dev, int wait) return 0; } -int libxl_device_pci_reset(libxl_ctx *ctx, unsigned int domain, unsigned int bus, - unsigned int dev, unsigned int func) -{ - char *reset = "/sys/bus/pci/drivers/pciback/do_flr"; - int fd, rc; - - fd = open(reset, O_WRONLY); - if (fd > 0) { - char *buf = libxl_sprintf(ctx, PCI_BDF, domain, bus, dev, func); - rc = write(fd, buf, strlen(buf)); - if (rc < 0) - XL_LOG(ctx, XL_LOG_ERROR, "write to %s returned %d", reset, rc); - close(fd); - return rc < 0 ? rc : 0; - } - if (errno != ENOENT) - XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "Failed to access pciback path %s", reset); - reset = libxl_sprintf(ctx, "/sys/bus/pci/devices/"PCI_BDF"/reset", domain, bus, dev, func); - fd = open(reset, O_WRONLY); - if (fd > 0) { - rc = write(fd, "1", 1); - if (rc < 0) - XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "write to %s returned %d", reset, rc); - close(fd); - return rc < 0 ? rc : 0; - } - if (errno == ENOENT) { - XL_LOG(ctx, XL_LOG_ERROR, "The kernel doesn't support PCI device reset from sysfs"); - } else { - XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "Failed to access reset path %s", reset); - } - return -1; -} - int libxl_wait_for_device_model(libxl_ctx *ctx, uint32_t domid, char *state, int (*check_callback)(libxl_ctx *ctx, diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index 76cef09bf5..3b2af3709e 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -536,3 +536,36 @@ int libxl_device_pci_init(libxl_device_pci *pcidev, unsigned int domain, return 0; } +int libxl_device_pci_reset(libxl_ctx *ctx, unsigned int domain, unsigned int bus, + unsigned int dev, unsigned int func) +{ + char *reset = "/sys/bus/pci/drivers/pciback/do_flr"; + int fd, rc; + + fd = open(reset, O_WRONLY); + if (fd > 0) { + char *buf = libxl_sprintf(ctx, PCI_BDF, domain, bus, dev, func); + rc = write(fd, buf, strlen(buf)); + if (rc < 0) + XL_LOG(ctx, XL_LOG_ERROR, "write to %s returned %d", reset, rc); + close(fd); + return rc < 0 ? rc : 0; + } + if (errno != ENOENT) + XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "Failed to access pciback path %s", reset); + reset = libxl_sprintf(ctx, "/sys/bus/pci/devices/"PCI_BDF"/reset", domain, bus, dev, func); + fd = open(reset, O_WRONLY); + if (fd > 0) { + rc = write(fd, "1", 1); + if (rc < 0) + XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "write to %s returned %d", reset, rc); + close(fd); + return rc < 0 ? rc : 0; + } + if (errno == ENOENT) { + XL_LOG(ctx, XL_LOG_ERROR, "The kernel doesn't support PCI device reset from sysfs"); + } else { + XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "Failed to access reset path %s", reset); + } + return -1; +} -- 2.30.2